package com.example.gameandroid;

import org.andengine.engine.Engine;
import org.andengine.entity.Entity;
import org.andengine.entity.sprite.AnimatedSprite;

import org.andengine.extension.physics.box2d.PhysicsWorld;
import org.andengine.opengl.texture.region.ITiledTextureRegion;

import com.badlogic.gdx.physics.box2d.Body;


public class Player extends Entity{
	
	private Body body;
	//private IAreaShape rec;
	private boolean onFloor;
	private AnimatedSprite player;

	public Player(Engine engine, ITiledTextureRegion playerTexture, float width, PhysicsWorld physicsWorld, Body body) {
		player = new AnimatedSprite(0, 0, playerTexture, engine.getVertexBufferObjectManager());
		this.body = body;
		attachChild(player);
		
		onFloor = true;

	}

	public boolean isOnFloor() {
		return onFloor;
	}
	
	public Body getBody(){
		return body;
	}

	public void setOnFloor(boolean onFloor) {
		this.onFloor = onFloor;
	}
		
	public AnimatedSprite getSprite(){
		return player;   
	}
	
	public void pular(){
		body.applyForce(0, -200, body.getPosition().x, body.getPosition().y);
	}
	
	public void correr(){
		body.applyForce(1, 0, body.getLocalCenter().x, body.getLocalCenter().y);
	}
	
	public void animaCorrer(){
		player.animate(new long[] {80,80,80,80,80,80,80,80,80}, new int[] {0,1,2,3,4,5,6,7,8}, true);
	}

	
	

}
